package com.j180.intercepter;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginInterceputer implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        System.out.println("进行登录的拦截===》》》");

        String islogin = (String) request.getSession().getAttribute("user");

        System.out.println(islogin+"*****");

        if(islogin!=null){
            return true;
        }else{

            response.sendRedirect("../login.jsp");
        }

        return false;
    }
}
